package com.wang.java.basic.features.reference;

import java.lang.ref.SoftReference;

public class SoftReferenceTest {
    public static void main(String[] args) {
        byte[] bytes = new byte[1024 * 1024];
        SoftReference<byte[]> softReference = new SoftReference(bytes);
        System.out.println(softReference.get());
        // 新分配对象，超过内存阈值，触发GC
        byte[] moreBytes = new byte[1024 * 1024];
        System.out.println(softReference.get());
    }
}
